<!DOCTYPE html>
<html lang="cmn-Hans" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>个人首页</title>
    <link rel="stylesheet" th:href="@{/frame/layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{/frame/flyres/css/global.css}">
</head>
<body>
<div th:replace="customer/top :: topBar"></div>
<div class="fly-home fly-panel">
    <img th:src="@{'/picture/getAvatar?fileName='+${show_customer.avatar}}" th:alt="${show_customer.username}">
    <h1>
        [[${show_customer.username}]]
        <i class="iconfont icon-wenda" th:if="${show_customer.gender} eq '保密'"></i>
        <i class="iconfont icon-nan" th:if="${show_customer.gender} eq '男'"></i>
        <i class="iconfont icon-nv" th:if="${show_customer.gender} eq '女'"></i>
        <br>
        <span style="color:#c00;">普通用户</span>
    </h1>
    <p class="fly-home-info">
        <i class="iconfont icon-kiss" title="积分"></i><span style="color: #FF7200;" th:text="${show_customer.integral}+'积分'"></span>
        <i class="iconfont icon-shijian"></i><span th:text="${show_customer.registertime}+'加入'"></span>
    </p>

    <p class="fly-home-sign" th:utext="${show_customer.signature}"></p>
    <!--用户自己查看自己的信息，就没有iscared信息，也就没有关注、发送消息的操作-->
        <div class="fly-sns" data-user="" th:if="${session.current_customer eq null || show_customer.phone!=session.current_customer.phone}">

<!--            游客-->
            <div th:if="${session.current_customer} eq null">
                <a href="javascript:" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend"
                   onclick="doCare(0)">关注此人</a>
                <a href="javascript:" class="layui-btn layui-btn-normal fly-imActive" data-type="chat"
                   onclick="showEdit(0)">发送消息</a>
            </div>
<!--            查看自己的主页不显示这两个按钮-->
<!--            查看外人主页-->
            <div th:if="${session.current_customer ne null && show_customer.phone!=session.current_customer.phone}">
                <a href="javascript:" class="layui-btn layui-btn-primary fly-imActive" data-type="addFriend"
                   onclick="doCare(1)" th:text="${iscared}? '取消关注':'关注此人'" th:onclick="${iscared}? 'doRemoveCare()':'doCare(1)'" id="careBtn"></a>
                <a href="javascript:" class="layui-btn layui-btn-normal fly-imActive" data-type="chat"
                   onclick="showEdit(1)">发送消息</a>
            </div>
        </div>
</div>

<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md6 fly-home-jie">
            <div class="fly-panel">
                <h3 class="fly-panel-title" th:text="${show_customer.username}+'最近上传的文档'"></h3>
                <ul class="jie-row">
                        <li th:each="item : ${show_customer.uploadeddoc}">
                            <a th:href="@{'/document/documentDetail?docid='+${item.docid}}" class="jie-title" th:text="${item.title}"></a>
                            <i th:text="${item.uploadtime}"></i>
                            <em class="layui-hide-xs" th:text="${item.hot}+'阅/'+${item.commentList.size()}+'评'"></em>
                        </li>
                </ul>
            </div>
        </div>

        <div class="layui-col-md6 fly-home-da">
            <div class="fly-panel">
                <h3 class="fly-panel-title" th:text="${show_customer.username}+'最近的评论'"></h3>
                <ul class="home-jieda">
                        <li th:each="aitem : ${show_customer.commentList}">
                            <p>
                                <span th:text="${aitem.publishtime}"></span>
                                在<a th:href="@{'/document/documentDetail?docid='+${aitem.document.docid}}" target="_blank" th:text="${aitem.document.title}"></a>中评论：
                            </p>
                            <div class="home-dacontent" th:utext="${aitem.content}">
                                <!--尝试给layer.photos加上这个属性试试：
                                <pre>
                                    full: true
                                </pre>
                                文档没有提及-->
                            </div>
                        </li>
                </ul>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/frame/layui/layui.js}"></script>
<script>
    function doRemoveCare() {
        layui.$.post('[[@{/care/removeCare}]]',{'other':[[${show_customer.phone * 6}]]},function (res){
            layui.$('#careBtn').attr('onclick','doCare(1)');
            layui.$('#careBtn').text('关注此人');
        });
    }
    function doCare(status) {
        if(status===0){
            layui.layer.msg("您尚未登录，请登录后重试");
        }else{
            layui.$.post('[[@{/care/addCare}]]',{'other':[[${show_customer.phone * 6}]]},function (res){
                layui.$('#careBtn').attr('onclick','doRemoveCare()');
                layui.$('#careBtn').text('取消关注');
            });
        }
    }
</script>
<script>
    layui.cache.page = 'user';
    layui.cache.user = {
        username: '游客'
        , uid: -1
        , avatar: '[[@{/frame/flyres/images/avatar/00.jpg}]]'
        , experience: 83
        , sex: '男'
    };
    layui.config({
        version: "3.0.0"
        , base: '/frame/flyres/mods/'
    }).extend({
        fly: 'index'
    }).use(['fly', 'element', 'layer'], function () {
        const element = layui.element;
        const layer = layui.layer;
        const $ = layui.$;

        window.showEdit = function (status) {
            if (status === 0) {
                layui.layer.msg("您尚未登录，请登录后重试");
            } else {
                const index = layer.open({
                    type: 2
                    , title: '发送消息'
                    , content: '[[@{/message/sendMessagePage}]]'
                    , area: ['550px', '406px']
                    , success: function (layero, index) {
                        const iframe = window['layui-layer-iframe' + index];
                        iframe.deliverValue([[${show_customer.phone * 6}]]);
                    }
                });
            }
        }
    });
</script>
</body>
</html>